package com.example.node;

import com.example.ProcessFlowContext;
import com.example.domain.Order;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.UUID;

@LiteflowComponent(id = "initOrder", name = "流程启动节点")
@Component
@Slf4j
public class InitNode extends NodeComponent {
    @Override
    public void process() throws Exception {
        ProcessFlowContext context = this.getContextBean(ProcessFlowContext.class);

        Order order = new Order(UUID.randomUUID().toString());
        order.setProductList(context.getProductList());
        context.setOrder(order);
        log.info("流程启动");
    }
}
